home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUTORC.ZIP / WORMIE.C < prev   
C/C++ Source or Header  |  1994-10-30  |  9KB  |  225 lines

  1. /* 
  2.   wormie.c
  3.   10/30/94
  4.   from wormie.pas
  5.   Adapted from Denthor's wormie.pas
  6.   Translated into C, from Denthor's VGA Trainer, by
  7.   Steve Pinault, scp@ohm.att.com
  8.   Compiled with Microsoft Visual C++ 1.5 (Microsoft C 8.0)
  9.   To compile:
  10.   First compile the subroutines in tutsubs.c with the batch file 
  11.   cltutsub.bat
  12.   Then compile any of the tutor programs with the batch file
  13.   cltut.bat
  14.   Example: C:>cltutsub
  15.            C:>cltut wormie.c
  16.            to compile this program.
  17. */
  18.  
  19. // Program T_holic;
  20. #include "tutheadr.h"
  21.  
  22. char Block[40][40] = {
  23.        {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
  24.        {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0},
  25.        {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
  26.        {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
  27.        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  28.        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  29.        {0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0},
  30.        {0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
  31.        {0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0},
  32.        {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0},
  33.        {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
  34.        {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
  35.        {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
  36.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  37.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  38.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  39.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  40.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  41.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  42.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  43.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  44.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  45.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  46.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  47.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  48.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  49.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  50.        {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
  51.        {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
  52.        {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
  53.        {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0},
  54.        {0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0},
  55.        {0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
  56.        {0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0},
  57.        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  58.        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  59.        {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
  60.        {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
  61.        {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0},
  62.        {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}
  63.        };
  64.  
  65.  
  66.    char WholePal[256][3];
  67.    int curx,cury,curcol;
  68.    int right,down;
  69.  
  70.  
  71. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  72. // Procedure PreparePalette;
  73. //    { This sets up the palette to have pretty gradients in it for our use }
  74. void PreparePalette()
  75. {
  76.    int loop;
  77.    for(loop=0;loop<30;loop++)
  78.    {
  79.       WholePal [loop][0]=loop*2;
  80.       WholePal [loop][1]=0;
  81.       WholePal [loop][2]=0;
  82.    }
  83.  
  84.    for(loop=30;loop<60;loop++)
  85.    {
  86.       WholePal [loop][0]=0;
  87.       WholePal [loop][1]=loop*2-30;
  88.       WholePal [loop][2]=0;
  89.    }
  90.  
  91.    for(loop=60;loop<90;loop++)
  92.    {
  93.       WholePal [loop][0]=0;
  94.       WholePal [loop][1]=0;
  95.       WholePal [loop][2]=loop*2-30;
  96.    }
  97.  
  98.    for(loop=90;loop<120;loop++)
  99.    {
  100.       WholePal [loop][0]=loop*2-30;
  101.       WholePal [loop][1]=loop*2-30;
  102.       WholePal [loop][2]=loop*2-30;
  103.    }
  104.  
  105.    for(loop=120;loop<150;loop++)
  106.    {
  107.       WholePal [loop][0]=loop*2-30;
  108.       WholePal [loop][1]=loop*2-30;
  109.       WholePal [loop][2]=0;
  110.    }
  111.  
  112.    for(loop=150;loop<180;loop++)
  113.    {
  114.       WholePal [loop][0]=0;
  115.       WholePal [loop][1]=loop*2-30;
  116.       WholePal [loop][2]=loop*2-30;
  117.    }
  118.  
  119.    for(loop=180;loop<210;loop++)
  120.    {
  121.       WholePal [loop][0]=loop*2-30;
  122.       WholePal [loop][1]=0;
  123.       WholePal [loop][2]=loop*2-30;
  124.    }
  125. }
  126.  
  127. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  128. // Procedure IngeniouslyMoveCurPos;
  129. //    { This moves the position of the block to put down around the screen }
  130. void IngeniouslyMoveCurPos()
  131. {
  132.    curcol = 1 + curcol%210;
  133.    if(right) curx += 4; else curx -= 3;
  134.    if(down)  cury += 3; else cury -= 2;
  135.  
  136.    if(curx > 250) right = 0;
  137.    if(cury > 150) down  = 0;
  138.  
  139.    if(curx < 10)  right = 1;
  140.    if(cury < 10)  down  = 1;
  141.  
  142. }
  143.  
  144.  
  145. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  146. // Procedure DrawBlock;
  147. //    { This draws the block onto the VGA screen }
  148. void DrawBlock()
  149. {
  150.    int xloop,yloop;
  151.    for(xloop=0;xloop<40;xloop++)
  152.       for(yloop=0;yloop<40;yloop++)
  153.         if(Block[yloop][xloop] == 1)
  154.             PutPixel(curx+xloop,cury+yloop,(char)curcol,VGA);
  155. }
  156.  
  157.  
  158. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  159. // Procedure StartSnakiepoo;
  160. //    { This is the proc where we set things up & set em in motion! ;-) }
  161. void StartSnakiepoo()
  162. {
  163.    curx=100;
  164.    cury=100;
  165.    curcol=1;
  166.    PreparePalette();
  167.    while(1)
  168.    {
  169.       if(_bios_keybrd(_KEYBRD_READY))break;
  170.       DrawBlock();
  171.       rotatepal(WholePal,1,210);  // CunninglyManipulatePalette;
  172.       IngeniouslyMoveCurPos();
  173.    }
  174.    FadeDown();
  175.    getch();
  176. }
  177.  
  178. void main()
  179. {
  180.    SetMCGA();
  181.    StartSnakiepoo();
  182.    SetText();
  183. }
  184. /*
  185. Begin
  186.    ClrScr;
  187.    Writeln ('Hi there!  This is a small little routine that Livewire');
  188.    Writeln ('and Denthor of ASPHYXIA threw together during lunch break');
  189.    Writeln ('at varsity. We first saw this routine in the T-Holic demo');
  190.    Writeln ('by Extreme a few months back, and decided to write it as');
  191.    Writeln ('a supliment to the ASPHYXIA VGA Demo Trainer Series on the');
  192.    Writeln ('MailBox BBS here in Durban.                              ');
  193.    Writeln;
  194.    Writeln ('The routine consists of a wormy type thing bouncing around');
  195.    Writeln ('the screen, and looks quite effective. The code is');
  196.    Writeln ('documented, and the concept behind it is so easy everyone');
  197.    Writeln ('should be able to understand it.                         ');
  198.    Writeln;
  199.    Writeln ('The Pal routines, setmcga, waitretrace etc. are taken');
  200.    Writeln ('directly from the ASPHYXIA Trainer Series, and you should');
  201.    Writeln ('read those to understand how they work.');
  202.    Writeln;
  203.    Writeln ('See the Trainer Series for how to get into contact with us.');
  204.    Writeln; Writeln;
  205.    Writeln ('Hit any key to continue ....                             ');
  206.    Readkey;
  207.    SetMCGA;
  208.    StartSnakiepoo;
  209.    SetText;
  210.    Writeln ('All done. This was a sample routine written by ASPHYXIA.');
  211.    Writeln ('Please read the ASPHYXIA Demo Trainer Series on the MailBox BBS,');
  212.    Writeln ('written by Denthor. You may reach DENTHOR under the name of GRANT');
  213.    Writeln ('SMITH on the MailBox BBS, or leave a message to ASPHYXIA on the');
  214.    Writeln ('ASPHYXIA BBS. Get the numbers from Roblist, or write to :');
  215.    Writeln ('             Grant Smith');
  216.    Writeln ('             P.O. Box 270');
  217.    Writeln ('             Kloof');
  218.    Writeln ('             3640');
  219.    Writeln ('We hope to hear from you soon!');
  220.    Writeln; Writeln;
  221.    Write   ('Hit any key to exit ...');
  222.    Readkey;
  223. End.
  224. */
  225.